<template>
    <div class="newsinfo-container">
        <!-- 大标题 -->
        <h3 class="title">{{photoinfo.title}}</h3>
        <!-- 子标题 -->
        <p class="subtitl">
            <span>发表时间：{{photoinfo.add_time | dateFormat}}</span>
            <span>点击：{{photoinfo.click}}次</span>
        </p>
        <hr>
        <!-- 缩略图区域-->
        <vue-preview :slides="list" @close="handleClose"></vue-preview>
    
        <!-- 图片内容区域 -->
        <div class="content" v-html="photoinfo.zhaiyao"></div>
        <!-- 评论子组件区域 -->
        <comment-box :id="this.id"></comment-box>
        
    </div>
</template>
<script>
import comment from '../subcomponents/comment.vue';
export default {
    data(){
        return {
            id: this.$route.params.id,//从路由中获取图片的id
            photoinfo:[],//图片详情
            list:[]//缩略图数组
        }
    },
    created(){
        this.getPhotoinfo();
        this.getThumbs();
    },
    methods:{
        getPhotoinfo(){
            this.$http.get('getimageinfo/'+this.id).then(result=>{
                console.log(result.body);
                if(result.body.status === 0){
                    this.photoinfo = result.body.data[0];
                }
            })
        },
        getThumbs(){
            this.$http.get("getthumbimages/"+this.id).then(result=>{
                console.log(result.body);
                if(result.body.status === 0){
                    result.body.data.forEach(item => {
                        item.w = 600;
                        item.h = 400;
                        item.msrc = item.src;
                    });
                    this.list = result.body.data;
                }
            })
        },
        handleClose () {
            console.log('close event')
        }
    },
    components:{
        "comment-box":comment
    }
}
</script>
<style lang="scss" >
.newsinfo-container{
    padding:3px;
    h3{
        color:#26a2ff;
        font-size: 15px;
        text-align: center;
        margin:15px 0;
    }
    .subtitle{
        display: flex;
        justify-content: space-between;
        font-size: 13px;
    }
    .content{
        font-size: 13px;
        line-height: 30px;
    }

    .my-gallery{
        img{
           width: 100%;
       }
    
       
   }
}
</style>

